#ifndef TEMPLATE_POINTERQUEEN_H_
#define TEMPLATE_POINTERQUEEN_H_

template <class Type>
class Queen
{
private:
	enum { SIZE = 10 };
	int _queenSize;
	Type * _items;
	int _front;
	int _rear;
public:
	explicit Queen(int queenSize=10);
	Queen(const Queen & queen);
	~Queen(){delete [] _items;}
	bool IsFull();
	bool IsEmpty();
	bool EnQueen(const Type & item);
	bool DeQueen(Type & item);
	Queen<Type> & operator = (const Queen<Type> & queen);
};

template<class Type>
Queen<Type>::Queen(int queenSize) : _queenSize(queenSize), _front(0), _rear(0)
{
	_items = new Type[_queenSize];
}

template<class Type>
Queen<Type>::Queen(const Queen & queen)
{
	_queenSize = queen._queenSize;
	_front = queen._front;
	_rear = queen._rear;
	_items = new Type[queen._queenSize];
	for (int i = 0; i < queen._queenSize; i++)
		_items[i] = queen._items[i];
}

template<class Type>
bool Queen<Type>::IsEmpty()
{
	return _front == _rear;
}

template<class Type>
bool Queen<Type>::IsFull()
{
	return (_rear - _front) == _queenSize;
}

template<class Type>
bool Queen<Type>::EnQueen(const Type & item)
{
	if ((_rear - _front) < _queenSize)
	{
		_items[_rear++] = item;
		return true;
	}
	else
		return false;
}

template<class Type>
bool Queen<Type>::DeQueen(Type & item)
{
	if (_rear != _front)
	{
		item = _items[_front++];
		return true;
	}
	else
		return false;
}

template<class Type>
Queen<Type> & Queen<Type>::operator=(const Queen<Type> & queen)
{
	if (this == queen)
		return *this;
	else
	{
		delete[]_items;
		_queenSize = queen._queenSize;
		_front = queen._front;
		_rear = queen._rear;
		_items = new Type[queen._queenSize];
		for (int i = 0; i < queen._queenSize; i++)
			_items = queen._items[i];
		return *this;
	}
}

#endif